import 'package:get/get.dart';

class RedisConfig {
  String? id;
  String name;
  String host;
  int port;
  String? username;
  String? password;
  bool isConnected;

  RedisConfig({
    this.id,
    required this.name,
    required this.host,
    required this.port,
    this.username,
    this.password,
    this.isConnected = false,
  });

  Map<String, dynamic> toJson() => {
    'id': id ?? DateTime.now().millisecondsSinceEpoch.toString(),
    'name': name,
    'host': host,
    'port': port,
    'username': username,
    'password': password,
    'isConnected': isConnected,
  };

  factory RedisConfig.fromJson(Map<String, dynamic> json) => RedisConfig(
    id: json['id'],
    name: json['name'],
    host: json['host'],
    port: json['port'],
    username: json['username'],
    password: json['password'],
    isConnected: json['isConnected'] ?? false,
  );
}
